import request from '@/utils/request'

export function getRoutes() {
  return request({
    url: '/vue-element-admin/routes',
    method: 'get'
  })
}

export function getDeviceGroups(data) {
  return request({
    url: '/api/ruo/device-group/page',
    method: 'post',
    data
  })
}

export function detail(id) {
  return request({
    url: `/api/ruo/device-group/${id}`,
    method: 'get'
  })
}

/**
 * 可绑定的设备列表
 * @param data
 */
export function getUnbindingDevices(data) {
  return request({
    url: '/api/ruo/device-group/device/unbinding',
    method: 'post',
    data
  })
}

export function addDeviceGroup(data) {
  return request({
    url: '/api/ruo/device-group',
    method: 'post',
    data
  })
}

export function updateDeviceGroup(data) {
  return request({
    url: '/api/ruo/device-group',
    method: 'patch',
    data
  })
}

/**
 * 解绑设备
 * @param data
 */
export function unbinding(id) {
  return request({
    url: `/api/ruo/device-group/device/unbinding/${id}`,
    method: 'delete'

  })
}

/**
 * 获取该设备组下面的设备 分页
 * @param data
 */
export function deviceInGroup(data) {
  return request({
    url: '/api/ruo/device-group/device',
    method: 'post',
    data
  })
}

export function deleteDeviceGroup(id) {
  return request({
    url: `/api/ruo/device-group/${id}`,
    method: 'delete'
  })
}
